package com.amado.easyui2.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.amado.easyui2.dao.ExportDrivingDao;
import com.amado.easyui2.domain.DrivingSchoolEntity;

public class ExportDrivingDaoImpl implements ExportDrivingDao {

	@Override
	public List<DrivingSchoolEntity> listAll() {
		Connection conn = JDBC.getConn();
		String sql = "select * from t_driving_school";
		PreparedStatement ps = null;
		ResultSet rs = null;
		List<DrivingSchoolEntity> driving = new ArrayList();
		try {
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery();
			while (rs.next()) {
				int i = 1;
				Long id = rs.getLong(i++);
				String drivingSchoolName = rs.getString(i++);
				String companyName = rs.getString(i++);
				String validTime = rs.getString(i++);
				String serviceCode = rs.getString(i++);
				String abbreviation = rs.getString(i++);
				String bhName = rs.getString(i++);
				String blNumber = rs.getString(i++);
				Date blTalidTime = rs.getTimestamp(i++);
				String bhFirstSolar = rs.getString(i++);
				String area = rs.getString(i++);
				String licenseNo = rs.getString(i++);
				String site = rs.getString(i++);
				String postalCode = rs.getString(i++);
				String businessScope = rs.getString(i++);
				String fn = rs.getString(i++);
				String legalPerson = rs.getString(i++);
				String phone = rs.getString(i++);
				String registerSerialNumber = rs.getString(i++);
				String approvalUnit = rs.getString(i++);
				String trafficApprovalNumber = rs.getString(i++);
				Date approvalDay = rs.getTimestamp(i++);
				String bhPopedom = rs.getString(i++);
				String economicNature = rs.getString(i++);
				String deleteLogo=rs.getString(i++);
				Date createTime=rs.getTimestamp(i++);
				Date updateTime=rs.getTimestamp(i++);
				String createName=rs.getString(i++);
				String updateName=rs.getString(i++);
				driving.add(new DrivingSchoolEntity(id, drivingSchoolName, companyName, validTime, serviceCode,
						abbreviation, bhName, blNumber, blTalidTime, bhFirstSolar, area, licenseNo, site, postalCode,
						businessScope, fn, legalPerson, phone, registerSerialNumber,approvalUnit,trafficApprovalNumber,approvalDay,bhPopedom,economicNature,deleteLogo,
						createTime,updateTime,createName,updateName));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return driving;
	}

}
